package com.wzdigit.wms.basic.enums;

import java.util.*;
import com.wzdigit.wms.basic.util.enums.SystemModuleEnum;

/**
 * 收货单---单据类型
 * 
 * @author Administrator
 *
 */
public enum AsnTypeEnum implements BaseEnum {

	/**
	 * 成品类型
	 */
    R01("R01", "生产自动交收", "生产自动交收", SystemModuleEnum.WMS),
    R02("R02", "采购入库", "采购入库", SystemModuleEnum.WMS),
    R03("R03", "调拨入库", "调拨入库", SystemModuleEnum.WMS),
	R04("R04", "销售退货", "销售退货", SystemModuleEnum.WMS),
	R05("R05", "还机(料)入库", "还机(料)入库", SystemModuleEnum.WMS),
	R06("R06", "免费入库", "免费入库", SystemModuleEnum.WMS),
	R07("R07", "无合同入库", "无合同入库", SystemModuleEnum.WMS),
    R08("R08", "零部件入库", "零部件入库", SystemModuleEnum.WMS),
    R09("R09", "公司间发货入库", "公司间发货入库", SystemModuleEnum.WMS),
    R10("R10", "公司间退货入库", "公司间退货入库", SystemModuleEnum.WMS),
    R96("R96", "生产手动交收", "生产手动交收", SystemModuleEnum.WMS),
    R97("R97", "退柜入库", "退柜入库", SystemModuleEnum.WMS),
    R98("R98", "初始化入库", "初始化入库", SystemModuleEnum.WMS),
    R99("R99", "其它入库", "其它入库", SystemModuleEnum.WMS),
    
    /**
     * 原材料类型
     */

    R11("R11", "生产退料", "生产退料", SystemModuleEnum.RAW),
    R12("R12", "委外退料", "委外退料", SystemModuleEnum.RAW),
    R13("R13", "VMI入库", "VMI入库", SystemModuleEnum.RAW),
    R14("R14", "送货单", "送货单", SystemModuleEnum.RAW),
    R15("R15", "销售入库", "销售入库(供应商退回)", SystemModuleEnum.RAW),
    R16("R16", "易损件退料", "易损件退料入库", SystemModuleEnum.RAW),
    R17("R17", "内销售后仓领料单入库", "内销售后仓领料单入库", SystemModuleEnum.RAW),
    R18("R18", "申购退料入库单", "申购入库单", SystemModuleEnum.RAW),
    R19("R19", "公司间交货入库", "公司间交货", SystemModuleEnum.RAW),
    R20("R20", "公司间退货入库", "公司间交货", SystemModuleEnum.RAW),
    R21("R21", "调拨入库", "公司间交货", SystemModuleEnum.RAW),
    R22("R22", "不同库位调拨(入)", "公司间交货", SystemModuleEnum.RAW),
    //R23("R23", "公司间出入", "公司间交货", SystemModuleEnum.RAW);

    //盘点入库
    R50("R50", "盘点入库", "盘点入库", SystemModuleEnum.RAW);
    /**
     * 枚举值
     */
    public String code;

    /**
     * 枚举名称
     */
    public String enumName;

    /**
     * 枚举实体类属性描述
     */
    public String description;

    /**
     * 系统模块标识
     */
    public SystemModuleEnum systemModule;

	AsnTypeEnum(String enumName, String description) {
		this.enumName = enumName;
		this.description = description;
	}

	AsnTypeEnum(String code, String enumName, String description) {
		this.code = code;
		this.enumName = enumName;
		this.description = description;
	}

	AsnTypeEnum(String code, String enumName, String description, SystemModuleEnum systemModule) {
		this.code = code;
		this.enumName = enumName;
		this.description = description;
		this.systemModule = systemModule;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getEnumName() {
		return enumName;
	}

	public void setEnumName(String enumName) {
		this.enumName = enumName;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public SystemModuleEnum getSystemModule() {
		return systemModule;
	}

	public void setSystemModule(SystemModuleEnum systemModule) {
		this.systemModule = systemModule;
	}

	public static AsnTypeEnum getEnumByCode(String enumCode) {
        AsnTypeEnum[] values = AsnTypeEnum.values();
        AsnTypeEnum samplingEnum = null;

        for (AsnTypeEnum value : values) {
            if (value.getCode().equals(enumCode)) {
                samplingEnum = value;
                break;
            }
        }
        return samplingEnum;
    }

    public static AsnTypeEnum getEnumByName(String enumName) {
        AsnTypeEnum[] values = AsnTypeEnum.values();
        AsnTypeEnum repairEnum = null;

        for (AsnTypeEnum value : values) {
            if (value.getEnumName() == enumName) {
                repairEnum = value;
            }
        }
        return repairEnum;
    }

    public static String getCodeByEnumNameAndDescription(String enumName, String enumDescription) {
        AsnTypeEnum[] values = AsnTypeEnum.values();
        for (AsnTypeEnum value : values) {
            if (Objects.equals(value.getDescription(), enumDescription)
                    && Objects.equals(value.getEnumName(), enumName)) {
                return value.getCode();
            }
        }
        return null;
    }

    public static Map<String, String> getEnumByDescription() {
        Map<String, String> enumMap = new HashMap<String, String>();
        AsnTypeEnum[] values = AsnTypeEnum.values();
        for (AsnTypeEnum value : values) {
        	enumMap.put(value.getCode(), value.getEnumName());
        }
        return enumMap;
    }
    
    public static Map<String, String> getEnumByDescription(String enumDescription) {
        Map<String, String> enumMap = new HashMap<String, String>();
        AsnTypeEnum[] values = AsnTypeEnum.values();
        for (AsnTypeEnum value : values) {
            if (Objects.equals(value.getDescription(), enumDescription)) {
                enumMap.put(value.getCode(), value.getEnumName());
            }
        }
        return enumMap;
    }

    public static List<Map<String, Object>> getEnumListByDescription(String enumDescription) {
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
        AsnTypeEnum[] values = AsnTypeEnum.values();
        for (AsnTypeEnum value : values) {
            if (Objects.equals(value.getDescription(), enumDescription)) {
                Map<String, Object> enumMap = new HashMap<String, Object>(2);
                enumMap.put("code", value.getCode());
                enumMap.put("name", value.getEnumName());
                list.add(enumMap);
            }
        }
        return list;
    }
    
	public static List<String> getEnumBySystemModule(SystemModuleEnum systemModule) {
		List<String> list = new ArrayList<>();
		AsnTypeEnum[] values = AsnTypeEnum.values();
		for (AsnTypeEnum value : values) {
			if (Objects.equals(value.getSystemModule(), systemModule)) {
				list.add(value.getCode());
			}
		}
		return list;
	}
    
    public static List<Map<String, Object>> getEnumListBySystemModule(SystemModuleEnum systemModule) {
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
        AsnTypeEnum[] values = AsnTypeEnum.values();
        for (AsnTypeEnum value : values) {
            if (Objects.equals(value.getSystemModule(), systemModule)) {
                Map<String, Object> enumMap = new HashMap<String, Object>(2);
                enumMap.put("code", value.getCode());
                enumMap.put("name", value.getEnumName());
                list.add(enumMap);
            }
        }
        return list;
    }


}
